﻿namespace Resharper.Abstractions.CodeDom.Statements.ThrowStatements
{
  using JetBrains.Annotations;
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using Resharper.Abstractions.CodeDom.Statements.TryStatements;
  using Resharper.Abstractions.CodeDom.TreeNodes;

  /// <summary>Defines the <see cref="TryStatementExtensions"/> class.</summary>
  public static class ThrowStatementExtensions
  {
    #region Public Methods

    /// <summary>Gets the selected literal expression.</summary>
    /// <param name="treeNode">The tree node.</param>
    /// <returns>Returns the selected literal expression.</returns>
    [CanBeNull]
    public static ThrowStatement GetThrowStatement([NotNull] this TreeNode treeNode)
    {
      var throwStatement = treeNode.InternalTreeNode as IThrowStatement;

      return throwStatement != null ? new ThrowStatement(throwStatement) : null;
    }

    #endregion
  }
}